package cn.ljy.mes.web.controller.backstage.mes.cartechnology;


import cn.ljy.authority.web.controller.backstage.BaseBackstageController;
import cn.ljy.common.annotation.LimitRequest;
import cn.ljy.common.model.result.ResponseData;
import cn.ljy.mes.model.MesCarTechnology;
import cn.ljy.mes.model.query.MesCarTechnologyQuery;
import cn.ljy.mes.service.MesCarTechnologyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

@Api(tags = "后台车型模块")
@RestController
@RequestMapping(value = "/backstage/mes/carTechnology")
public class MesCarTechnologyController extends BaseBackstageController<MesCarTechnology, MesCarTechnologyQuery,String> {

    @Autowired
    private MesCarTechnologyService baseService;

    @Override
    public String getAuthorityPrefix() {
        return "mes:carTechnology"; // 定义模块权限前缀
    }


    @ApiOperation(value = "订单状态管理",notes = "状态的修改只能通过这个函数")
    @PreAuthorize("hasAuthority('mes:carTechnology:edit')")
    @LimitRequest
    @PatchMapping("/{id}/enabled")
    public ResponseData updateStatus(@PathVariable String id, @NotNull(message = "启用状态不能为空") Boolean enabled) {
        baseService.changeEnabled(id, enabled);
        return ResponseData.success(null);
    }

}
